import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class RmlogW {

	/**
	 * @param args
	 */
	static String strDays = "$DAY";
	static String strNode = "LKYLEXAT01";
	static String strRmCom = "| xargs rm -f;";
	static String[] ARR_COM = new String[] {
			"find /sw/anylink/jeus5/logs/" + strNode + "/" + strNode
					+ "_container9    -type f -mtime +" + strDays + " -name '"
					+ strNode + "*.log'",
			"find /sw/anylink/jeus5/logs/JeusServer    -type f -mtime +"
					+ strDays + " -name '*.log'       ",
			"find /sw/anylink/tmax/com/alog            -type f -mtime +"
					+ strDays + " -name '*.log'       ",
			"find /sw/anylink/jeus5/logs/anylink       -type f -mtime +"
					+ strDays + " -name '*.log.*'       ",
			"find /sw/anylink/tmax/log/ulog            -type f -mtime +"
					+ strDays + " -name '*.log'       " };

	public static void main(String[] args) {

		System.out.println(Arrays.toString(args));
		try {
			// System.out.println("Disk space...(Before)");
			// System.out.println(Runtime.getRuntime().exec("df -k |grep any").getOutputStream());
			for (int i = 0; i < ARR_COM.length; i++) {
				/*
				
				
				ARR_COM[i] = ARR_COM[i].replace("$DAY", args[0]);
				
				if(args.length > 1){
					if (args[1].toUpperCase().equals("Y")) {
						ARR_COM[i] = ARR_COM[i] + strRmCom;
					}
				}
				 */
				String s = null;

				System.out.println("runnung... " + "dir");
				Process p = Runtime.getRuntime().exec("dir", null,
						new File("c:/"));
				int rst = p.waitFor();
				if (rst == 0) {
					BufferedReader stdInput = new BufferedReader(
							new InputStreamReader(p.getInputStream()));
					// read the output from the command
					while ((s = stdInput.readLine()) != null) {
						System.out.println(s);
					}
				} else {
					BufferedReader stdErr = new BufferedReader(
							new InputStreamReader(p.getErrorStream()));
					// read the output from the command
					while ((s = stdErr.readLine()) != null) {
						System.out.println(s);
					}
				}
			}
			// System.out.println("Disk space...(After)");
			// System.out.println(Runtime.getRuntime().exec("df -k |grep any").getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
